package com.rede.didiok.admin.web;

import java.util.Collection;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.rede.didiok.admin.service.AdminService;
import com.rede.didiok.common.utils.R;


/**
 * 管理员表
 *
 * @author Rede
 * @email didiok@foxmail.com
 * @date 2023-08-07 18:21:17
 */
@RestController
@RequestMapping("/admin/feign/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    /**
     * 通过 id 获取管理员昵称
     */
    @GetMapping("/getNicknameById")
    R getAdminNicknameById(String uid){
        return R.ok().setData(adminService.getNicknameById(uid));
    }

    /**
     * 通过 ids 获取管理员
     */
    @GetMapping(value = "/getAdminByUid")
    R getAdminByUid(@RequestParam("adminUid") String adminUid){
        return R.ok().setData(adminService.getAdminByUid(adminUid));
    }

    /**
     * 通过 ids 获取管理员(不包括 photoUrl)
     */
    @PostMapping(value = "/getUserListWithoutAvatarByIds")
    R getUserListWithoutAvatarByIds(@RequestBody Set<String> adminUidList){
        return R.ok().setData(adminService.getUserListWithoutAvatarByIds(adminUidList));
    }


    /**
     * 根据 userUid 查询绑定的管理员账号数量
     */
    @GetMapping(value = "/countAdminByUserUid")
    Integer countAdminByUserUid(@RequestParam("userUid") String userUid){
        return adminService.countAdminByUserUid(userUid);
    }

    /**
     * 根据uids获取管理员列表
     * @param adminUidList
     * @return
     */
    @PostMapping("/getAdminListByUids")
    R getAdminListByUids(@RequestBody Collection<String> adminUidList){
        return R.ok().setData(adminService.getAdminListByUids(adminUidList));
    }
    /**
     * 通过 id 更新管理员密码
     * @param adminUid
     * @return
     */
    @GetMapping("/updateAdminPasswordById")
    R updateAdminPasswordById(@RequestParam("adminUid") String adminUid,@RequestParam("password") String password){
        return R.ok().setData(adminService.updateAdminPasswordById(adminUid, password));
    }
}
